#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int n,m,st,ed,f,T,flag,ans,cnt;
double p[100005],xl,v;
struct node{
    double si,vi,ai,di;
}car[100005];
map<int,int>mp;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        cin>>n>>m>>xl>>v;
        mp.clear();
        ans=0,cnt=0,flag=0;
        for(int i=0;i<n;i++){
            cin>>car[i].di>>car[i].vi>>car[i].ai;
            if(car[i].ai!=0)
                flag=1;
            if(car[i].ai<0)
                car[i].si=min(car[i].vi*car[i].vi/(-car[i].ai*2)+car[i].di,xl);
            else
                car[i].si=xl;
        }
        f=0;
        for(int i=0;i<m;i++){
            cin>>p[i];
            if(i!=0)
                if(p[i]<p[i-1])
                    f=1;
        }
        if(f==1)
            sort(p,p+m);
        if(flag==0){
            for(int i=0;i<n;i++){
                if(car[i].di>p[m-1])
                    continue;
                if(car[i].vi>v)
                    ans++;
            }
            cout<<ans<<" "<<m-1<<endl;
            continue;
        }
        for(int i=0;i<n;i++){
            if(car[i].di>p[m-1]||car[i].si<p[0])
                continue;
            int l=0,r=m-1,mid;
            while(l<r){
                mid=(l+r)/2;
                if(p[mid]>=car[i].di)
                    r=mid;
                else
                    l=mid+1;
            }
            st=l,l=0,r=m-1;
            while(l<r){
                mid=(l+r+1)/2;
                if(p[mid]<=car[i].si)
                    l=mid;
                else
                    r=mid-1;
            }ed=l;
            if(car[i].ai<0){
                if(car[i].vi*car[i].vi+2*car[i].ai*(p[st]-car[i].di)>v*v){
                    ans++;
                    if(st+1<m){
                        if(mp[st]==0&&p[st+1]>=car[i].di&&car[i].vi*car[i].vi+2*car[i].ai*(p[st+1]-car[i].di)<=v*v)
                            mp[st]=1,cnt++;
                        else{
                            int ttt=1,fflag=0;
                            if(mp[st]==1)
                                continue;
                            while(st+ttt<m){
                                if(p[st+ttt]>=car[i].di&&car[i].vi*car[i].vi+2*car[i].ai*(p[st+ttt]-car[i].di)>v*v){
                                    if(mp[st+ttt]==1){
                                        fflag=1;
                                        break;
                                    }
                                }
                            }
                            if(fflag==0)
                                mp[st]=1,cnt++;
                        }
                    }
                }
            }
            else{
                if(car[i].vi*car[i].vi+2*car[i].ai*(p[ed]-car[i].di)>v*v){
                    ans++;
                    if(mp[ed]==0)
                        mp[ed]=1,cnt++;
                }
            }
        }
        cout<<ans<<" "<<m-cnt<<endl;
    }
    return 0;
}
